import React,{ Component , PropTypes } from 'react';
import * as CounterActions from '../actions/user'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

class Users extends Component {
	render(){
		const {users,getUsers} = this.props;
		return(
			<div>
				<div onClick={getUsers}>点击此处获取数据</div>
				<ul>
					{users.map((u,index) => 
						<li key={index}>{u.name}</li>
					)}
				</ul>
			</div>
		);
	} 
}

Users.propTypes = {
  users: PropTypes.arrayOf(PropTypes.object).isRequired
};

function mapStateToProps(state) {
  return {
    users: state.users
  }
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators(CounterActions, dispatch);
}

export default connect(mapStateToProps,mapDispatchToProps)(Users)